<?php if (!defined('THINK_PATH')) exit(); /*a:3:{s:79:"/home/wwwroot/www.lxlhome.com/public/../application/admin/view/works/index.html";i:1557280458;s:71:"/home/wwwroot/www.lxlhome.com/application/admin/view/common/header.html";i:1555692011;s:70:"/home/wwwroot/www.lxlhome.com/application/admin/view/common/crumb.html";i:1555408352;}*/ ?>
<!doctype html>
<html  class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>图集列表-LXL</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="/static/admin/css/font.css">
    <link rel="stylesheet" href="/static/common/css/public.css">
    <link rel="stylesheet" href="/static/common/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/static/admin/css/xadmin.css">
    <script type="text/javascript" src="/static/common/jq/jquery.min.js"></script>
    <script type="text/javascript"src="/static/common/lib/md5/md5.min.js"></script>
    <script src="/static/common/lib/layui/layui.js" charset="utf-8"></script>

    <script type="text/javascript" src="/static/admin/js/xadmin.js"></script>
    <script type="text/javascript" src="/static/admin/js/cookie.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="/static/common/lib/ie/html5.min.js"></script>
    <script src="/static/common/lib/ie/respond.min.js"></script>
    <![endif]-->
    <script>
        // 是否开启刷新记忆tab功能
        // var is_remember = false;
    </script>
</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
          <a href="<?php echo url('Index/welcome'); ?>">首页</a>
          <a><cite>内容管理</cite></a>
          <a><cite>图集列表</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:window.location.reload();" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so">
            <input class="layui-input" autocomplete="off" placeholder="开始日" name="start" id="start">
            <input class="layui-input" autocomplete="off" placeholder="截止日" name="end" id="end">
            <input type="text" name="title" placeholder="请输入文章标题名称" autocomplete="off" class="layui-input">
            <button class="layui-btn" lay-submit="" lay-filter="search"><i class="layui-icon">&#xe615;</i></button>
        </form>
    </div>
    <table class="layui-table" id="table" lay-filter="table"></table>
</div>
<script type="text/html" id="toolbarTop">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="delAll"><i class="layui-icon">&#xe640;</i>批量删除</button>
        <button class="layui-btn  layui-btn-normal layui-btn-sm" lay-event="add"><i class="layui-icon">&#xe608;</i>增加
        </button>
    </div>
</script>
<script type="text/html" id="operation">
    <button class="layui-btn  layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon">&#xe642;</i>修改
    </button>
    <button class="layui-btn  layui-bg-green layui-btn-xs" lay-event="view"><i class="layui-icon">&#xe621</i>查看
    </button>
    <button class="layui-btn  layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon">&#xe640;</i>删除
    </button>

</script>
<script type="text/html" id="statusTpl">
    <!-- 这里的 checked 的状态只是演示 -->
    <input type="checkbox" name="istop" value="{{d.id}}" lay-skin="switch" lay-text="是|否" lay-filter="switch" {{
           d.istop == 1 ? 'checked' : '' }}>
</script>
<script type="text/html" id="nameTpl">
    {{ d.column.name }}
</script>
<script type="text/html" id="picTpl">
    <img src="{{ d.pic }}" alt="">
</script>
<script>
    layui.use(['table', 'form', 'laydate'], function () {
        var laydate = layui.laydate;
        var table = layui.table;
        var form = layui.form;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });

        //执行表格实例化
        var table_instance = table.render({
            elem: '#table'
            , height: 'full-162'
            , toolbar: '#toolbarTop'
            , url: "<?php echo url('lists'); ?>"
            , method: 'post'
            , defaultToolbar: ['filter']
            , limit: 14
            , page: true
            ,size: 'lg' //小尺寸的表格
            , cols: [[
                {type: 'checkbox'},
                {field: 'id', title: 'ID', unresize: true, width: 80},
                {field: 'pic', title: '缩略图', width: 120, templet: "#picTpl", align: 'center'},
                {field: 'title', title: '文章标题'},
                {field:'name', title: '所属栏目', templet: "#nameTpl", width: 120, hide:true},
                {field: 'author', title: '发布者', align: 'center',unresize: true, width: 120},
                {field: 'status', title: '发布状态', align: 'center',unresize: true, width: 110},
                {field: 'isopen', title: '浏览权限', align: 'center',unresize: true, width: 110},
                {field: 'istop', title: '是否置顶', templet: "#statusTpl", align: 'center', unresize: true, width: 100},
                {field: 'create_time', title: '发布时间', align: 'center',unresize: true, width: 160},
                {title: '操作', toolbar: "#operation", align: 'center', unresize: true, width: 250},
            ]]
        });
        //监听单元格编辑
        table.on('edit(test)', function (obj) {
            var value = obj.value //得到修改后的值
                , data = obj.data //得到所在行所有键值
                , field = obj.field; //得到字段
            layer.msg('[ID: ' + data.id + '] ' + field + ' 字段更改为：' + value);
        });
        form.on('submit(search)', function (data) {

            //这里以搜索为例
            table_instance.reload({
                where: { //设定异步数据接口的额外参数，任意设
                    where: {
                        title: data.field.title
                        , start: data.field.start
                        , end: data.field.end
                    }
                }
                , page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            return false;
        });
        form.on('switch(switch)', function (data) {
            let value = data.elem.checked ? 1 : 0;
            $.post(
                '<?php echo url("status"); ?>',
                {data: {istop: value, id: data.value}},
                function (reg) {
                    let icon = {icon: 5};
                    if (0 === reg.code) {
                        icon = {icon: 6};
                    }
                    layer.msg(reg.msg, icon);
                },
                'json'
            );
        });
        //监听工具条
        table.on('tool(table)', function (obj) {
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象

            if (layEvent === 'del') { //删除
                layer.confirm('真的删除行么', {icon: 3}, function (index) {
                    $.post('<?php echo url("del"); ?>', {data: [data.id]}, function (reg) {
                        let icon = {icon: 5};
                        if (0 === reg.code) {
                            icon = {icon: 6};
                            obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
                        }
                        layer.msg(reg.msg, icon);
                    }, 'json');
                    layer.close(index);
                    //向服务端发送删除指令
                });
            } else if (layEvent === 'edit') { //编辑
                x_admin_show('修改', '<?php echo url("edit"); ?>?id=' + data['id'],'','',true);
            }
        });
        //头工具栏事件
        table.on('toolbar(table)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);

            switch (obj.event) {
                case 'add':
                    x_admin_show('添加', '<?php echo url("add"); ?>','','',true);
                    break;
                case 'delAll':
                    if (0 === checkStatus.data.length) {
                        layer.msg('至少选择一项', {icon: 5});
                    } else {
                        let data = [];
                        layui.each(checkStatus.data, function (k, v) {
                            data.push(v.id);
                        });
                        layer.confirm('真的要删除么', {icon: 3}, function (index) {
                            //向服务端发送删除指令
                            $.post('<?php echo url("del"); ?>', {data: data}, function (reg) {
                                let icon = {icon: 5};
                                if (0 === reg.code) {
                                    icon = {icon: 6};
                                }
                                layer.msg(reg.msg, icon,function(){
                                    layer.close(index);
                                    table_instance.reload();
                                });
                            }, 'json');
                        });
                    }
                    break;
            }
        });
    });
</script>
</body>

</html>